//
// Created by jmdvirus on 2020/3/27 下午4:57.
// Copyright (c) 2020 benewtech All rights reserved.
//
//     ******          *             *--*
//       ||            *             |
//       ||  *--*--*---*  * *-********--*
//   *  //   *  *  *   *\ / ||  |  |    |
//    **    *  *  *---* *  *   *--* *--*
//

#ifndef CUTEDEVICE_CMMEDIAOPERATIONBASE_H
#define CUTEDEVICE_CMMEDIAOPERATIONBASE_H

#include "opencv2/opencv.hpp"

class CMMediaOperationBase
{
public:
    CMMediaOperationBase();
    virtual ~CMMediaOperationBase();

    virtual void setParam(int width, int height);

    virtual bool isOpened() = 0;
    virtual int open(int index) = 0;
    virtual int close() = 0;

    virtual int readYUV(unsigned char **data) = 0;
    virtual int readYUV(unsigned char **data, size_t *len)
    {
        return -1;
    };
    // readYUV with *len need call to free
    virtual void readClear(){};
    virtual int readMat(cv::Mat &frame)
    {
        return -1;
    };

protected:
    int m_width;
    int m_height;

    unsigned char *m_buf;
    unsigned int m_bufSize;
};

#endif  // CUTEDEVICE_CMMEDIAOPERATIONBASE_H
